package KeTangLian;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;

import javax.management.Query;

public class Demo4 {
	public static void main(String[] args) { 
		Scanner scanner=new Scanner(System.in);
		System.out.println("请输入开始时间  yyyy-MM-dd");
		String date=scanner.next();
		System.out.println("请输入截止时间  yyyy-MM-dd");
		String date1=scanner.next();
		
		System.out.println("\t\t\t"+"新闻标题列表");
		System.out.println("编号\t创建者\t创建时间\t\t\t标题");
		String sql="SELECT newsid,newstitle,newsauthor,addtime from newsinfo WHERE addtime BETWEEN '"+date+"' and '"+date1+"'";
		QueryDataResult rSet1=DBManager.excuteQuery(sql);
		try {
		if (rSet1.rs!=null) {
				while (rSet1.rs.next()) {
					System.out.println(rSet1.rs.getInt("newsid")+"\t"+rSet1.rs.getString("newsauthor")
							+"\t"+rSet1.rs.getString("addtime")+"\t"+rSet1.rs.getString("newstitle"));
				}
			} else {
				System.out.println("没有符合的数据");
			   }
			}catch (SQLException e) {
				e.printStackTrace();
		}
		rSet1.close();
	}

}
